﻿<UserControl x:Class="PresentationAid.Control.NotificationControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:tb="clr-namespace:Hardcodet.Wpf.TaskbarNotification;assembly=Hardcodet.Wpf.TaskbarNotification"
             mc:Ignorable="d" 
             d:DesignHeight="200" d:DesignWidth="400">
    <UserControl.Resources>
        <Style x:Key="CloseButtonStyle"  TargetType="{x:Type Button}">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="Button">
                        <Border Name="ButtonBorder" CornerRadius="12" BorderBrush="#FFFFFF" BorderThickness="2" Width="24" Height="24">
                            <Path Name="CloseButtonIcon" Data="F1M-1774.05,-6263.81L-1787.51,-6277.27 -1773.22,-6291.56C-1769.23,-6295.55 -1769.24,-6302.03 -1773.21,-6306.01 -1777.19,-6309.98 -1783.67,-6309.99 -1787.66,-6305.99L-1801.95,-6291.71 -1816.79,-6306.55C-1820.79,-6310.55 -1827.26,-6310.54 -1831.24,-6306.55 -1835.22,-6302.58 -1835.23,-6296.11 -1831.24,-6292.12L-1816.39,-6277.27 -1830.4,-6263.25C-1834.4,-6259.26 -1834.38,-6252.8 -1830.4,-6248.82 -1826.42,-6244.84 -1819.96,-6244.82 -1815.96,-6248.82L-1801.95,-6262.83 -1788.49,-6249.37C-1784.5,-6245.38 -1778.03,-6245.39 -1774.06,-6249.37 -1770.07,-6253.35 -1770.06,-6259.82 -1774.05,-6263.81" Stretch="Uniform" Fill="#FFFFFF" Width="10" Height="10" Margin="0,0,0,0" RenderTransformOrigin="0.5,0.5">
                                <Path.RenderTransform>
                                    <TransformGroup>
                                        <TransformGroup.Children>
                                            <RotateTransform Angle="0" />
                                            <ScaleTransform ScaleX="1" ScaleY="1" />
                                        </TransformGroup.Children>
                                    </TransformGroup>
                                </Path.RenderTransform>
                            </Path>
                        </Border>

                        <ControlTemplate.Triggers>
                            <Trigger Property="Button.IsPressed" Value="True">
                                <Setter TargetName="ButtonBorder" Property="BorderBrush" Value="#333333" />
                                <Setter TargetName="CloseButtonIcon" Property="Fill" Value="#333333" />
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        
        <Storyboard x:Key="FadeIn">
            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="MainGrid" Storyboard.TargetProperty="(UIElement.Opacity)">
                <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
                <SplineDoubleKeyFrame KeyTime="00:00:01" Value="1"/>
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>
        <Storyboard x:Key="FadeOut" Completed="OnFadeOutCompleted" >
            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="MainGrid" Storyboard.TargetProperty="(UIElement.Opacity)">
                <SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
                <SplineDoubleKeyFrame KeyTime="00:00:00.3000000" Value="0.2"/>
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>
    </UserControl.Resources>

    <UserControl.Triggers>
        <EventTrigger RoutedEvent="tb:TaskbarIcon.BalloonShowing">
            <BeginStoryboard Storyboard="{StaticResource FadeIn}" x:Name="FadeInBeginStoryboard" />
        </EventTrigger>
        <EventTrigger RoutedEvent="tb:TaskbarIcon.BalloonClosing">
            <BeginStoryboard Storyboard="{StaticResource FadeOut}" x:Name="FadeOutBeginStoryboard"/>
        </EventTrigger>
    </UserControl.Triggers>

    <Grid Name="MainGrid" Width="300" Margin="10" MouseEnter="MainBorderMouseEnter" MouseLeave="MainBorderMouseLeave">
        <Border Name="MainBorder" CornerRadius="10" Opacity="0.67" Background="Black" BorderBrush="#FFFFFF">
        </Border>

        <Grid Margin="15,15,15,13">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="50" />
                <ColumnDefinition />
            </Grid.ColumnDefinitions>

            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition />
            </Grid.RowDefinitions>

            <Image Name="NotificationImageElement" HorizontalAlignment="Left" VerticalAlignment="Top" Grid.RowSpan="2" Source="/PresentationAid;component/Resources/Images/Icons/warning_32.png" Width="32" Height="32" />

            <TextBlock Name="NotificationTitleTextBlock" Grid.Column="1" FontWeight="Bold" Foreground="White" Margin="0,0,0,15" >PresentationAid</TextBlock>

            <TextBlock Name="NotificationTextTextBlock" Grid.Column="1" Grid.Row="2" TextWrapping="Wrap" Width="220" Foreground="White">Notification text.</TextBlock>
        </Grid>

        <Button Name="CloseButton" Width="24" Height="24" Margin="5" HorizontalAlignment="Left" VerticalAlignment="Top" Click="CloseButtonClick" Style="{StaticResource CloseButtonStyle}" />
    </Grid>
</UserControl>
